<!DOCTYPE html>
<html lang="zh" class="body-full-height">
    <head>        
        <title>王者荣耀对战平台 — — 登录</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <css href="__PUBLIC__/Plugins/ui-frame/ui.css" />
        <css href="__PUBLIC__/css/Admin-default.css" />
    </head>

    <body>
        <div class="login-container">
            <div class="login-box animated fadeInDown">
                <div class="login-logo"><h2>王者荣耀对战平台后台</h2></div>
                <div class="login-body">
                    <div class="login-title"><strong>欢迎使用</strong>, 请登录</div>
                    <form action="{:U('Login/login')}" class="form-horizontal" method="post">
                    <div class="form-group">
                        <div class="col-md-12">
                            <input name="username" id="username" type="text" class="form-control" placeholder="你的账号"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-12">
                            <input name="password" id="password" type="password" class="form-control" placeholder="你的密码"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-6">
                            <a href="#" class="btn btn-link btn-block">忘记密码?</a>
                        </div>
                        <div class="col-md-6">
                            <button type="button" onclick="login()" class="btn btn-info btn-block">登录</button>
                        </div>
                    </div>
                    </form>
                </div>
                <div class="login-footer">
                    <div class="pull-left">
                        &copy; 2017 王者荣耀对战平台
                    </div>
                    <div class="pull-right">
                        <a href="#">关于</a> |
                        <a href="#">隐私</a> |
                        <a href="#">联系我们</a>
                    </div>
                </div>
            </div>            
        </div>
        <div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title" id="myModalLabel">提示</h4>
                    </div>
                    <div class="modal-body" id="hint_content">
                    </div>
                    <div class="modal-footer">
                        <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <!--<button type="button" class="btn btn-primary">Save changes</button>-->
                    </div>
                </div>
            </div>
        </div>
    	<!-- 在登录页，预加载系统所需js脚本 -->
        <js href="__PUBLIC__/Plugins/jquery/jquery-2.1.1.min.js" />
        <js href="__PUBLIC__/Plugins/jquery/jquery-ui.js" />
        <js href="__PUBLIC__/Plugins/bootstrap/bootstrap.js" />
        <js href="__PUBLIC__/Plugins/datatables/jquery-dataTables.js" />
        <js href="__PUBLIC__/Plugins/bootstrap/bootstrap-datepicker.js" />
        <js href="__PUBLIC__/Plugins/bootstrap/bootstrap-select.js" />
        <js href="__PUBLIC__/Plugins/ui-frame/plugins.js" />
        <js href="__PUBLIC__/Plugins/ui-frame/actions.js" />
        <js href="__PUBLIC__/Plugins/dropzone/dropzone.js" />
    </body>
    <script type="text/javascript">
        // 在被嵌套时就刷新上级窗口
        if (window.parent != window) {
            window.parent.location.reload(true);
        }
        function login() {
            $.ajax({
                type: "POST",
                url: "__URL__/login",
                data: {username: $("#username").val(),
                    password: $("#password").val(),
                },
                dataType: "json",
                success: function (data) {
                    if (data.check) {
                        window.location = data.url;
                    }
                    else {
                        $("#hint_content").empty().append(data.message);
                        $("#my-alert").modal('show');
//                    $('#code_img').click();
                    }
                },
                error: function (data) {
                    $("#hint_content").empty().append('请求超时');
                    $("#my-alert").modal('show');
                }
            });
        }
    </script>
</html>